﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace testYJKControl
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != null)
            {
                DateTime begintime = DateTime.Now;//获取开始时间
                string str = YJKSControl.init(@"C:\YJKS\YJKS_5_1\yjks.exe", "5.1");
                YJKSControl.RunCmd("yjk_opennew", textBox1.Text);
                YJKSControl.RunCmd("yjk_repairex", "");
                YJKSControl.RunCmd("yjk_save", "");
                YJKSControl.RunCmd("yjk_formnode", "");
                YJKSControl.RunCmd("yjk_setlayersupport", "");
                YJKSControl.RunCmd("yjkspre_genmodrel", "");
                YJKSControl.RunCmd("yjktransload_tlplan", "");
                YJKSControl.RunCmd("yjktransload_tlvert", "");
                YJKSControl.RunCmd("SetCurrentLabel", "IDSPRE_ROOT");
                YJKSControl.RunCmd("yjkdesign_dsncalculating_all", "");
                YJKSControl.RunCmd("SetCurrentLabel", "IDDSN_DSP");
                DateTime endtime = DateTime.Now;//获取开始时间
                TimeSpan otime = endtime.Subtract(begintime);
                MessageBox.Show("运行耗时：" + otime.TotalMinutes + "分钟");
            }
            else
            {

                MessageBox.Show("请选择YJK模型路径!");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title= "请选择YJK模型路径";
            dialog.Filter = "yjk模型数据（*.yjk)|*.yjk";
            if(dialog.ShowDialog()==DialogResult.OK)
            {
                textBox1.Text = dialog.FileName.ToString();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
